package com.ee.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.ee.bean.Equipment;
import com.ee.bean.User;
import com.ee.dao.EquipmentDao;
@Component("equipmentDao")
public class EquipmentDaoImpl implements EquipmentDao {
	
	private HibernateTemplate hibernateTemplate;
	
	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}
	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}
	
	@Override
	public void saveEquipment(Equipment equipment) {
		hibernateTemplate.save(equipment);
	}

	@Override
	public void deleteEquipment(Equipment equipment) {
		hibernateTemplate.delete(equipment);
	}

	@Override
	public Equipment findEquipmentById(int id) {
		return hibernateTemplate.get(Equipment.class, id);
	}

	@Override
	public List<Equipment> findAllEquipments() {
		String hql = "from Equipment equipment";
		List<Equipment> equipments = (List<Equipment>)hibernateTemplate.find(hql);
		return equipments;
	}

	@Override
	public void update(Equipment equipment) {
		hibernateTemplate.update(equipment);
	}

}
